<?php

class pradminComponents extends sfComponents
{
	public function executeStatus_id()
	{
		if( $product->getStatus_id() == MyConstants::OBJ_STATUS_ACTIVE )
		{
			return link_to(image_tag('news_active.png', __('alt="deactivate" title="Deactivate" border="0"')), 'product/deactivate?id=' . $product->getId());

		} else	{

			return link_to(image_tag('news_inactive.png', __('alt="activate" title="Activate" border="0"')), 'product/activate?id=' . $product->getId());
		}
	}

    public function executePhoto()
    {
		$this->isPhoto = false;
		$product = ProductPeer::retrieveByPk($this->getRequestParameter('id'));
		$c = new Criteria();
		$c->add( FilesPeer::OBJ_ID,  $this->getRequestParameter('id'));
		$c->add( FilesPeer::OBJ_TYPE, MyConstants::TYPE_PRODUCT );
		$photo = FilesPeer::doSelectOne($c);
		if( $photo )
		{
			$this->isPhoto = true;
			$this->photoName = $photo->getUname();
			$this->photoForUrl = $photo->getNameforurl();
		}
    }
	
    public function executeSel_category()
    {
        $main = Tree::getTreeByLabel('PRODUCTS', sfContext::getInstance()->getUser()->getCulture());
        if( $main[0]['children'] )
        {
            $this->tree = $main[0]['children'];
        }
    }

}
